package org.moore.view;

import org.moore.utils.Data;

import javax.swing.*;
import java.awt.*;

import static org.moore.utils.Button.getjButton;

// 游戏传播港口主界面组件类
public class HomeLabel extends JLabel {
	// 定义步数模式
    private final JButton stepMode;
    // 定义时间模式
    private final JButton timeMode;
    // 定义游戏说明按钮
    private final JButton description;
    // 定义退出游戏按钮
    private final JButton exitGame;

    public HomeLabel() {
        // 设置步数模式按钮并添加
        stepMode = getjButton(Data.BUTTON_ICON_2ND, Data.FONT);
        stepMode.setText("步数模式");
        stepMode.setBounds(70,150,200,150);
        stepMode.setActionCommand("step");
        this.add(stepMode);
        // 设置时间模式按钮并添加
        timeMode = getjButton(Data.BUTTON_ICON_2ND, Data.FONT);
        timeMode.setText("时间模式");
        timeMode.setBounds(350,150,200,150);
        timeMode.setActionCommand("time");
        this.add(timeMode);
        // 设置游戏说明按钮并添加
        description = getjButton(Data.BUTTON_ICON_2ND, Data.FONT);
        description.setText("游戏说明");
        description.setBounds(180,350,200,150);
        description.setActionCommand("description");
        this.add(description);
        // 设置退出游戏按钮并添加
        exitGame = getjButton(Data.BUTTON_ICON_2ND, Data.FONT);
        exitGame.setText("退出游戏");
        exitGame.setBounds(460,350,200,150);
        exitGame.setActionCommand("exit");
        this.add(exitGame);
    }
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        // 使用g2d绘制以修复抗锯齿
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        // 绘制标题
        g2d.drawImage(Data.TITLE_IMAGE_2ND,1100,75,100,500,null);
    }

    public JButton getStepMode() {
        return stepMode;
    }

    public JButton getTimeMode() {
        return timeMode;
    }

    public JButton getDescription() {
        return description;
    }

    public JButton getExitGame() {
        return exitGame;
    }

}
